import parole
from parole.colornames import colors
from parole.display import interpolateRGB
import pygame, random

import sim, main
from util import *
from dungeon import makeFloor, Room, TemplateRoom
import dungeon  

doorGenerator = parole.map.MapObjectGenerator("doorGenerator", 
        lambda: sim.Door('door', 100, parole.map.AsciiTile('/',
            colors['White'], bg_rgb=None), parole.map.AsciiTile('+',
                colors['White'])))
windowGenerator = parole.map.MapObjectGenerator("windowGenerator", 
        lambda: sim.Obj('glass window', 100, parole.map.AsciiTile(' ',
            colors['PaleTurquoise'], bg_rgb=colors['PaleTurquoise']),
            blockLOS=False, blockMove=True), clearFirst=True)
wallGenerator = parole.map.MapObjectGenerator("wallGenerator", 
        lambda: sim.Obj('wooden wall', 100, parole.map.AsciiTile('#',
            colors['Sienna'], bg_rgb=colors['Sienna']), blockLOS=True,
            blockMove=True), clearFirst=True)

template = \
"""
##-###-###-##--##-###-###-##
#[  h  ]#          #[  h  ]#
#[  o  ]# @      " #[  o  ]#
-[  h  ]#          #[  h  ]-
#                          #
#                          #
##-##-##-####++####-##-##-##
"""[1:]

legend = {
     '[':    parole.map.MapObjectGenerator("", 
            lambda: sim.Obj('bookshelf', 10, parole.map.AsciiTile('[',
                colors['SaddleBrown']),
                blockMove=True, massNoun=False, startsVowel=False),
            clearFirst=False),
    
     ']':    parole.map.MapObjectGenerator("", 
            lambda: sim.Obj('bookshelf', 10, parole.map.AsciiTile(']',
                colors['SaddleBrown']),
                blockMove=True, massNoun=False, startsVowel=False),
            clearFirst=False),

     '"':    parole.map.MapObjectGenerator("", 
            lambda: sim.Obj('musty tome', 10, parole.map.AsciiTile('"',
                colors['SaddleBrown']),
                blockMove=False, massNoun=False, startsVowel=False),
            clearFirst=False),
    
     'o':    parole.map.MapObjectGenerator("", 
            lambda: sim.Obj('study table', 10, parole.map.AsciiTile('o',
                colors['SaddleBrown']),
                blockMove=True, massNoun=False, startsVowel=False),
            clearFirst=False),

     'h':    parole.map.MapObjectGenerator("", 
            lambda: sim.Obj('chair', 10, parole.map.AsciiTile('h',
                colors['SaddleBrown']),
                blockMove=False, massNoun=False, startsVowel=False),
            clearFirst=False),

     '@':   dungeon.thingGenerator('npcs', 'librarian'),

     '#':   wallGenerator,

     '+':   doorGenerator,

     '-':   windowGenerator,
}

floorColor1 = colors['DarkKhaki']
floorColor2 = colors['SandyBrown']
floorName = 'tiled floor'
mixture = 0.3

diggable = [
    (13,4),
    (14,4),
]


class library(TemplateRoom):
    def __init__(self, pos):
        TemplateRoom.__init__(self, template, legend, diggable, pos,
                floorColor1, floorColor2, mixture, floorName)


roomClass = library



